**************************************************
********* Table 4 and Appendix A4: Likelihood of
********* Ballot Presence, ***********************
********* Post-2000 and Post-2010 ****************
********* Redistricting Ballots ******************
**************************************************

do "do_files/prep_GRACE_data/load_prep_GRACE_data.do"
do "do_files/prep_GRACE_data/ballot_level_prep.do"

* state level variables
egen stateyear_latpoppct = mean(latpoppct), by(stateyear)

* generate latpop_cat variable to capture mean dist latpoppct for a given state/year
gen latpop_cat=1 if stateyear_latpoppct<=.1
replace latpop_cat=2 if stateyear_latpoppct>=.100001 & stateyear_latpoppct<=.2

replace latpop_cat=3 if  stateyear_latpoppct>=.200001
replace latpop_cat=0 if latpop_cat==.

* main redistricting period model to report out for tables
eststo, title(Latina): quietly probit ballot_latwpres openmmdproportion  latpop_cat postred2010 latpoppct afampoppct asampoppct    tlimit  legprof  distrepubstr    multimem  candperseat allincfmt educcolldeg unemppct if postred2010==1  | postred2000==1 

eststo, title(Latino): quietly probit ballot_latmpres openmmdproportion  latpop_cat postred2010  latpoppct afampoppct asampoppct     tlimit  legprof  distrepubstr    multimem  candperseat allincfmt educcolldeg unemppct if postred2010==1  | postred2000==1 

estout, cells(b(star fmt(3)) se(par fmt(2))) legend label varlabels(_cons constant) stats( N, fmt(0) label(N))

* clear eststo for displaying future tables
eststo clear

* pausing for users who might be looping through all replication files
pause

